package cn.bandeqing.finance.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.base.resp.Table;
import cn.bandeqing.finance.req.*;
import cn.bandeqing.finance.resp.*;
import cn.bandeqing.finance.rpc.IFinanceRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/finance")
@RestController
@Tag(name = "财务")
public class FinanceController {

    @DubboReference
    private IFinanceRpc financeRpc;

    @Operation(summary = "checkUserWithdraw")
    @PostMapping("/checkUserWithdraw")
    public Resp<Void> checkUserWithdraw(@RequestBody @Valid CheckUserWithdrawReq req) {
        return financeRpc.checkUserWithdraw(req);
    }

    @Operation(summary = "accountUserWithdraw")
    @PostMapping("/accountUserWithdraw")
    public Resp<Void> accountUserWithdraw(@RequestBody @Valid AccountUserWithdrawReq req) {
        return financeRpc.accountUserWithdraw(req);
    }

    @Operation(summary = "checkWorkerWithdraw")
    @PostMapping("/checkWorkerWithdraw")
    public Resp<Void> checkWorkerWithdraw(@RequestBody @Valid CheckWorkerWithdrawReq req) {
        return financeRpc.checkWorkerWithdraw(req);
    }

    @Operation(summary = "accountWorkerWithdraw")
    @PostMapping("/accountWorkerWithdraw")
    public Resp<Void> accountWorkerWithdraw(@RequestBody @Valid AccountWorkerWithdrawReq req) {
        return financeRpc.accountWorkerWithdraw(req);
    }

    @Operation(summary = "userWallteRecordTable")
    @PostMapping("/userWallteRecordTable")
    public Resp<Table<FinanceUserWalletRecordTable>> userWallteRecordTable(@RequestBody @Valid FinanceUserWalletRecordTableReq req) {
        return financeRpc.userWallteRecordTable(req);
    }

    @Operation(summary = "userWallteChange")
    @PostMapping("/userWallteChange")
    public Resp<Void> userWallteChange(@RequestBody @Valid FinanceUserWalletChangeReq req) {
        return financeRpc.userWallteChange(req);
    }

    @Operation(summary = "userWallteTable")
    @PostMapping("/userWallteTable")
    public Resp<Table<FinanceUserWalletTable>> userWallteTable(@RequestBody @Valid FinanceUserWalletTableReq req) {
        return financeRpc.userWallteTable(req);
    }

    @Operation(summary = "workerWallteRecordTable")
    @PostMapping("/workerWallteRecordTable")
    public Resp<Table<FinanceWorkerWalletRecordTable>> workerWallteRecordTable(@RequestBody @Valid FinanceWorkerWalletRecordTableReq req) {
        return financeRpc.workerWallteRecordTable(req);
    }

    @Operation(summary = "workerWallteChange")
    @PostMapping("/workerWallteChange")
    public Resp<Void> workerWallteChange(@RequestBody @Valid FinanceWorkerWalletChangeReq req) {
        return financeRpc.workerWallteChange(req);
    }

    @Operation(summary = "workerWallteTable")
    @PostMapping("/workerWallteTable")
    public Resp<Table<FinanceWorkerWalletTable>> workerWallteTable(@RequestBody @Valid FinanceWorkerWalletTableReq req) {
        return financeRpc.workerWallteTable(req);
    }

    @Operation(summary = "costRemove")
    @PostMapping("/costRemove")
    public Resp<Void> costRemove(@RequestBody @Valid FinanceCostRemoveReq req) {
        return financeRpc.costRemove(req);
    }

    @Operation(summary = "workerSelect")
    @PostMapping("/workerSelect")
    public Resp<List<LabelValue>> workerSelect(@RequestBody @Valid FinanceWorkerSelectReq req) {
        return financeRpc.workerSelect(req);
    }

    @Operation(summary = "userSelect")
    @PostMapping("/userSelect")
    public Resp<List<LabelValue>> userSelect(@RequestBody @Valid FinanceWorkerSelectReq req) {
        return financeRpc.userSelect(req);
    }

    @Operation(summary = "costSettlement")
    @PostMapping("/costSettlement")
    public Resp<Void> costSettlement(@RequestBody @Valid FinanceCostSettlementReq req) {
        financeRpc.costSettlement(req);
        return Resp.success();
    }

    @Operation(summary = "创建或更新")
    @PostMapping("/costSaveOrUpdate")
    public Resp<Void> costSaveOrUpdate(@RequestBody @Valid FinanceCostSaveOrUpdateReq req) {
        financeRpc.costSaveOrUpdate(req);
        return Resp.success();
    }

    @Operation(summary = "costTable")
    @PostMapping("/costTable")
    public Resp<Table<FinanceOrderCostTable>> costTable(@RequestBody @Valid FinanceOrderCostTableReq req) {
        return financeRpc.costTable(req);
    }

    /**
     * 核销
     */
    @Operation(summary = "writeOff")
    @PostMapping("/writeOff")
    public Resp<Void> writeOff(@RequestBody @Valid WriteOffReq req) {
        return financeRpc.writeOff(req);
    }

    /**
     * 交款
     */
    @Operation(summary = "handIn")
    @PostMapping("/handIn")
    public Resp<Void> handIn(@RequestBody @Valid HandInReq req) {
        return financeRpc.handIn(req);
    }

    @Operation(summary = "表格")
    @PostMapping("/table")
    public Resp<Table<FinanceOrderTable>> table(@RequestBody @Valid FinanceOrderTableReq req) {
        return financeRpc.table(req);
    }

}
